"""

取出列表内的偶数
"""
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


# while循环取出偶数

def while_list():
    index = 0
    new_list = []
    while index < len(my_list):
        if my_list[index] % 2 == 0:
            new_list.append(my_list[index])
        index += 1
    print(f"while循环取出的偶数：{new_list}")


while_list()


# for循环取出偶数
def for_list():
    new_list = []
    for i in my_list:
        if i % 2 == 0:
            new_list.append(i)

    print(f"for循环取出偶数：{new_list}")


for_list()
